// 纯函数
// 下面例子是非纯函数, 函数中代用了变量
const discount = 12;
const calculatePrices = (price) => price * discount;
const prices = calculatePrices(200);
console.log('----price', prices);
// 纯函数
const calculatePrice = (price, discount) => price * discount;
const price = calculatePrice(200, 2);
console.log('-------纯函数---------', price);
//---
let a = [1, 2, 3, 4, 5, 6];
let z = [1, 2, 3, 4, 5, 6];
let dd = [1, 2, 3, 4, 5, 6];
const b = z.slice(1, 3); // 纯函数,原数组没有改变
const c = a.splice(1, 3); // 非纯函数, 原数组发生改变
const d = dd.pop(); // 非纯函数, 原数组发生改变
console.log(z,'-----------',b);
console.log(a,'-----------',c);
console.log(dd,'-----------',d);